﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter10.Section2
{
    public class Example03
    {
        public Example03()
        {
        }
        private string result;
        public string Result
        {
            get { return result; }
        }
        public void Compute()
        {
            Science.Mathematics.Complex[,] x 
                = new Science.Mathematics.Complex[2,2];
            x[0, 0] = new Science.Mathematics.Complex(1.0 * (1.0 / Math.Sqrt(3.0)), 0.0);
            x[0, 1] = new Science.Mathematics.Complex(1.0 * (1.0 / Math.Sqrt(3.0)), -1.0 * (1.0 / Math.Sqrt(3.0)));
            x[1, 0] = new Science.Mathematics.Complex(1.0 * (1.0 / Math.Sqrt(3.0)), 1.0 * (1.0 / Math.Sqrt(3.0)));
            x[1, 1] = new Science.Mathematics.Complex(-1.0 * (1.0 / Math.Sqrt(3.0)), 0.0);
      
            L.HermitianMatrix H = new L.HermitianMatrix(x);

            H.Diagonalize();

            result += H.Eigenvalue[0].ToString() + "\r\n";

            result += H.EigenvectorComplex[0].ToString() + "\r\n";

            result += H.Eigenvalue[1].ToString() + "\r\n";

            result += H.EigenvectorComplex[1].ToString() + "\r\n";
        }
    }
}
/*
1
0.627963030199554 +I 0.627963030199554
0 +I 0.459700843380983

-1
0.325057583671868 +I 0.325057583671868
0 -I 0.888073833977115
*/
